class Flicker{
    constructor(opt) {
        this.target = opt.target //目标dom
        this.opacity = opt.opacity || [0, 1]
        this.duration = opt.duration || 0.1
        this.count = opt.count || 5
        this.repeat = opt.repeat || 1
        this.repeatDelay = opt.repeatDelay || 3
        this.onStart = opt.onStart
        this.onComplete = opt.onComplete
        return this.init()
    }
    init() {
        if (!this.target) {
            return
        }
        let tl = new TimelineMax({
            repeat: this.repeat,
            repeatDelay: this.repeatDelay
        })
        let tw2 = TweenMax.fromTo(
            this.target,
            this.duration,
            {
                opacity: this.opacity[0]
            },
            {
                opacity: this.opacity[1],
                repeat: this.count,
                onStart: () => {
                    console.log(1)
                    if (typeof this.onStart === 'function') {
                        this.onStart()
                    }
                },
                onComplete: () => {
                    console.log(2)
                    if (typeof this.onComplete === 'function') {
                        this.onComplete()
                    }
                }
            }
        )
        tl.add(tw2)
        return tl
    }
}
export default Flicker;
